:root {
    --primary-color: #0366d6;
    --secondary-color: #f6f8fa;
    --text-color: #24292e;
    --border-color: #e1e4e8;
    --sidebar-width: 280px;
    --header-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
    background-color: var(--secondary-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* 头部样式 */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    gap: 15px;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-color);
    transition: color 0.2s;
}

.theme-toggle:hover {
    color: var(--primary-color);
}

/* 侧边栏样式 */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background-color: #fff;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px 15px;
    transition: transform 0.3s ease;
    -webkit-overflow-scrolling: touch; /* 改善iOS滚动体验 */
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: calc(var(--header-height) + 20px);
    left: 20px;
    z-index: 999;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

/* 添加遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 997;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.nav-section {
    margin-bottom: 25px;
}

.nav-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6a737d;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: 5px;
}

.nav-link {
    display: block;
    padding: 10px 12px; /* 增加触摸区域 */
    color: var(--text-color);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

.nav-link:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.nav-link.active {
    background-color: #e3f2fd;
    color: var(--primary-color);
    font-weight: 500;
}

/* 主内容区域 */
.main-container {
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    flex: 1;
    padding: 30px;
    /*max-width: 900px;*/
    margin: 0 auto;
    width: 100%;
}

.markdown-body {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 搜索框样式 */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(3, 102, 214, 0.1);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #6a737d;
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
    z-index: 996;
    top: 85vh;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background-color: #0256cc;
    transform: translateY(-2px);
}

/* 图片样式 */
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 15px 0;
}

/* 表格样式 */
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
}

.markdown-body table th,
.markdown-body table td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.markdown-body table th {
    background-color: var(--secondary-color);
    font-weight: 600;
}

/* 代码块样式 */
.markdown-body pre {
    background-color: #f6f8fa;
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    margin: 15px 0;
}

.markdown-body code {
    background-color: rgba(175, 184, 193, 0.2);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 85%;
}

.markdown-body pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

/* 响应式设计 */
/* 平板设备 */
@media (max-width: 1024px) {
    .content-wrapper {
        padding: 25px 20px;
    }
    
    .markdown-body {
        padding: 25px;
    }
}

/* 小型平板和大型手机 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 998;
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar-toggle {
        display: block;
    }

    .main-container {
        margin-left: 0;
    }

    .content-wrapper {
        padding: 20px 15px;
    }

    .markdown-body {
        padding: 20px 15px;
    }
    
    .header-title {
        font-size: 18px;
    }
    
    /* 表格横向滚动 */
    .markdown-body table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* 代码块优化 */
    .markdown-body pre {
        padding: 12px;
        font-size: 14px;
    }
}

/* 中型手机 */
@media (max-width: 576px) {
    .header-content {
        padding: 0 15px;
    }
    
    .header-title {
        font-size: 16px;
    }
    
    .sidebar {
        width: 75%;
        max-width: 280px;
    }
    
    .content-wrapper {
        padding: 15px 10px;
    }
    
    .markdown-body {
        padding: 15px 10px;
    }
    
    .markdown-body h1 {
        font-size: 24px;
    }
    
    .markdown-body h2 {
        font-size: 20px;
    }
    
    .markdown-body h3 {
        font-size: 18px;
    }
    
    /* 返回顶部按钮优化 */
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        right: 20px;
    }
    
    /* 搜索框优化 */
    .search-input {
        padding: 12px 40px 12px 15px;
        font-size: 16px; /* 防止iOS缩放 */
    }
}

/* 小型手机 */
@media (max-width: 480px) {
    .header-title {
        font-size: 15px;
    }
    
    .sidebar-toggle {
        top: calc(var(--header-height) + 15px);
        left: 15px;
        padding: 6px 10px;
    }
    
    .content-wrapper {
        padding: 12px 8px;
    }
    
    .markdown-body {
        padding: 12px 8px;
    }
    
    .markdown-body h1 {
        font-size: 22px;
    }
    
    .markdown-body h2 {
        font-size: 18px;
    }
    
    .markdown-body h3 {
        font-size: 16px;
    }
    
    .markdown-body p {
        font-size: 15px;
        line-height: 1.6;
    }
    
    .markdown-body ul, .markdown-body ol {
        padding-left: 20px;
    }
    
    .markdown-body li {
        margin-bottom: 8px;
    }
    
    /* 返回顶部按钮进一步优化 */
    .back-to-top {
        width: 40px;
        height: 40px;
        bottom: 15px;
        right: 15px;
    }
    
    /* 代码块进一步优化 */
    .markdown-body pre {
        padding: 10px;
        font-size: 13px;
        overflow-x: auto;
    }
    
    .markdown-body code {
        font-size: 13px;
    }
}

/* 超小屏幕手机 */
@media (max-width: 360px) {
    .header-title {
        font-size: 14px;
    }
    
    .markdown-body {
        padding: 10px 6px;
    }
    
    .markdown-body h1 {
        font-size: 20px;
    }
    
    .markdown-body h2 {
        font-size: 17px;
    }
    
    .markdown-body h3 {
        font-size: 15px;
    }
    
    .markdown-body p {
        font-size: 14px;
    }
}

/* 加载动画 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 暗色主题 */
body.dark-theme {
    --primary-color: #58a6ff;
    --secondary-color: #0d1117;
    --text-color: #e6edf3; /* 使用更高可读性的文字颜色 */
    --border-color: #30363d;
}

body.dark-theme header,
body.dark-theme .sidebar {
    background-color: #010409; /* 更浅的背景色 */
}

body.dark-theme .markdown-body {
    background-color: #010409; /* 统一背景色 */
    color: var(--text-color);
}

body.dark-theme .markdown-body table th {
    background-color: #161b22;
}

body.dark-theme .markdown-body pre {
    background-color: #161b22;
}

body.dark-theme .nav-link:hover {
    background-color: #21262d;
}

body.dark-theme .nav-link.active {
    background-color: #0969da;
}

body.dark-theme .sidebar-overlay {
    background-color: rgba(1, 4, 9, 0.8); /* 调整遮罩层透明度 */
}

/* 移动端优化 */
/* 防止移动端横向滚动 */
body {
    overflow-x: hidden;
}

/* 改善移动端滚动体验 */
.main-container {
    -webkit-overflow-scrolling: touch;
}

/* 移动端图片优化 */
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 15px 0;
    touch-action: manipulation; /* 改善触摸交互 */
}

/* 移动端链接优化 */
.markdown-body a {
    color: var(--primary-color);
    text-decoration: none;
    word-break: break-word; /* 防止长链接溢出 */
}

.markdown-body a:hover {
    text-decoration: underline;
}

/* 移动端列表优化 */
.markdown-body ul,
.markdown-body ol {
    padding-left: 25px;
}

.markdown-body li {
    margin-bottom: 8px;
    line-height: 1.6;
}

/* 移动端引用块优化 */
.markdown-body blockquote {
    margin: 15px 0;
    padding: 10px 15px;
    border-left: 4px solid var(--border-color);
    background-color: var(--secondary-color);
    border-radius: 0 4px 4px 0;
}

/* 移动端分割线优化 */
.markdown-body hr {
    height: 1px;
    background-color: var(--border-color);
    border: none;
    margin: 20px 0;
}

/* 暗色主题下的移动端优化 */
body.dark-theme .markdown-body blockquote {
    background-color: #161b22;
}

body.dark-theme .markdown-body hr {
    background-color: #30363d;
}
